{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}

module Storage.Queries.OrphanInstances.TransporterConfig where

import qualified Data.Aeson
import qualified Data.Text
import qualified Domain.Types.Location
import qualified Domain.Types.TransporterConfig
import Kernel.Beam.Functions
import Kernel.External.Encryption
import qualified Kernel.External.Notification.FCM.Types
import Kernel.Prelude
import qualified Kernel.Prelude
import qualified Kernel.Types.Common
import Kernel.Types.Error
import qualified Kernel.Types.Id
import Kernel.Utils.Common (CacheFlow, EsqDBFlow, MonadFlow, fromMaybeM, getCurrentTime)
import qualified Kernel.Utils.Common
import qualified Storage.Beam.TransporterConfig as Beam
import qualified Storage.Queries.Transformers.TransporterConfig

instance FromTType' Beam.TransporterConfig Domain.Types.TransporterConfig.TransporterConfig where
  fromTType' (Beam.TransporterConfigT {..}) = do
    fcmUrl' <- Kernel.Prelude.parseBaseUrl fcmUrl
    analyticsConfig' <- Storage.Queries.Transformers.TransporterConfig.parseAnalyticsConfig merchantOperatingCityId analyticsConfig
    driverWalletConfig' <- Storage.Queries.Transformers.TransporterConfig.parseDriverWalletConfig merchantOperatingCityId driverWalletConfig
    subscriptionConfig' <- Storage.Queries.Transformers.TransporterConfig.parseSubscriptionConfig merchantOperatingCityId subscriptionConfig
    pure $
      Just
        Domain.Types.TransporterConfig.TransporterConfig
          { aaEnabledClientSdkVersion = fromMaybe Storage.Queries.Transformers.TransporterConfig.fallBackVersionInText aaEnabledClientSdkVersion,
            aadhaarImageResizeConfig = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< aadhaarImageResizeConfig,
            aadhaarVerificationRequired = aadhaarVerificationRequired,
            acStatusCheckGap = acStatusCheckGap,
            actualRideDistanceDiffThreshold = actualRideDistanceDiffThreshold,
            actualRideDistanceDiffThresholdIfWithinPickupDrop = actualRideDistanceDiffThresholdIfWithinPickupDrop,
            allowDashboardToPassVehicleDetails = allowDashboardToPassVehicleDetails,
            allowDefaultPlanAllocation = allowDefaultPlanAllocation,
            allowDriverToUseFleetRcs = allowDriverToUseFleetRcs,
            allowDuplicateAadhaar = allowDuplicateAadhaar,
            allowDuplicateGst = allowDuplicateGst,
            allowDuplicatePan = allowDuplicatePan,
            allowRcUnlinkWhenDriverOffline = allowRcUnlinkWhenDriverOffline,
            allowedReferralEntities = maybe [] (mapMaybe (readMaybe . Data.Text.unpack)) allowedReferralEntities,
            analyticsConfig = analyticsConfig',
            approxRideDistanceDiffThreshold = approxRideDistanceDiffThreshold,
            arrivalTimeBufferOfVehicle = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< arrivalTimeBufferOfVehicle,
            arrivedPickupThreshold = fromMaybe 100 arrivedPickupThreshold,
            arrivedStopThreshold = arrivedStopThreshold,
            arrivingPickupThreshold = arrivingPickupThreshold,
            automaticRCActivationCutOff = automaticRCActivationCutOff,
            avgSpeedOfVehicle = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< avgSpeedOfVehicle,
            badDebtBatchSize = badDebtBatchSize,
            badDebtRescheduleTime = Kernel.Utils.Common.secondsToNominalDiffTime badDebtRescheduleTime,
            badDebtSchedulerTime = Kernel.Utils.Common.secondsToNominalDiffTime badDebtSchedulerTime,
            badDebtTimeThreshold = badDebtTimeThreshold,
            bankErrorExpiry = Kernel.Utils.Common.secondsToNominalDiffTime bankErrorExpiry,
            bookAnyVehicleDowngradeLevel = bookAnyVehicleDowngradeLevel,
            bulkWaiveOffLimit = fromMaybe 200 bulkWaiveOffLimit,
            cacheOfferListByDriverId = cacheOfferListByDriverId,
            cachedDevicesOSForSearchRequest = maybe [] (mapMaybe (readMaybe . Data.Text.unpack)) cachedDevicesOSForSearchRequest,
            canAddCancellationFee = canAddCancellationFee,
            canDowngradeToHatchback = canDowngradeToHatchback,
            canDowngradeToSedan = canDowngradeToSedan,
            canDowngradeToTaxi = canDowngradeToTaxi,
            canSuvDowngradeToHatchback = fromMaybe False canSuvDowngradeToHatchback,
            canSuvDowngradeToTaxi = canSuvDowngradeToTaxi,
            canSwitchToInterCity = canSwitchToInterCity,
            canSwitchToRental = canSwitchToRental,
            cancellationDistDiff = cancellationDistDiff,
            cancellationFee = cancellationFee,
            cancellationFeeCycle = cancellationFeeCycle,
            cancellationFeeDisputeLimit = cancellationFeeDisputeLimit,
            cancellationFeeDisputeWindow = cancellationFeeDisputeWindow,
            cancellationFeeVendor = cancellationFeeVendor,
            cancellationRateCalculationThreshold = cancellationRateCalculationThreshold,
            cancellationRateSlabConfig = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< cancellationRateSlabConfig,
            cancellationRateThresholdDaily = cancellationRateThresholdDaily,
            cancellationRateThresholdWeekly = cancellationRateThresholdWeekly,
            cancellationRateWindow = cancellationRateWindow,
            cancellationTimeDiff = Kernel.Utils.Common.secondsToNominalDiffTime cancellationTimeDiff,
            checkImageExtractionForDashboard = checkImageExtractionForDashboard,
            coinConversionRate = coinConversionRate,
            coinExpireTime = Kernel.Utils.Common.secondsToNominalDiffTime coinExpireTime,
            coinFeature = coinFeature,
            considerDriversForSearch = considerDriversForSearch,
            considerSpecialZoneRideChargesInFreeTrial = considerSpecialZoneRideChargesInFreeTrial,
            considerSpecialZoneRidesForPlanCharges = considerSpecialZoneRidesForPlanCharges,
            createDocumentRequired = createDocumentRequired,
            createdAt = createdAt,
            crossTravelCities = crossTravelCities,
            currency = fromMaybe Kernel.Types.Common.INR currency,
            dailyConditionCooldownTimeHours = dailyConditionCooldownTimeHours,
            dailyMinRidesForBlocking = dailyMinRidesForBlocking,
            dailyMinRidesForNudging = dailyMinRidesForNudging,
            dailyOffenceSuspensionTimeHours = dailyOffenceSuspensionTimeHours,
            deactivateRCOnUnlink = deactivateRCOnUnlink,
            defaultPopupDelay = defaultPopupDelay,
            deleteDriverBankAccountWhenLinkToFleet = deleteDriverBankAccountWhenLinkToFleet,
            demandHotspotsConfig = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< demandHotspotsConfig,
            disableDriverWhenUnlinkingVehicle = disableDriverWhenUnlinkingVehicle,
            disableListScheduledBookingAPI = fromMaybe False disableListScheduledBookingAPI,
            distanceUnit = Kernel.Prelude.fromMaybe Kernel.Types.Common.Meter distanceUnit,
            distanceWeightage = distanceWeightage,
            dlNumberVerification = dlNumberVerification,
            dpBlackListedGeohash = dpBlackListedGeohash,
            dpGeoHashPercision = dpGeoHashPercision,
            dpWhiteListedGeohash = dpWhiteListedGeohash,
            driverAutoPayExecutionTime = Kernel.Utils.Common.secondsToNominalDiffTime driverAutoPayExecutionTime,
            driverAutoPayExecutionTimeFallBack = Kernel.Utils.Common.secondsToNominalDiffTime driverAutoPayExecutionTimeFallBack,
            driverAutoPayNotificationTime = Kernel.Utils.Common.secondsToNominalDiffTime driverAutoPayNotificationTime,
            driverCallingOption = driverCallingOption,
            driverDistanceToPickupThresholdOnCancel = driverDistanceToPickupThresholdOnCancel,
            driverDistanceTravelledOnPickupThresholdOnCancel = driverDistanceTravelledOnPickupThresholdOnCancel,
            driverDrivenSearchReqExpiry = Kernel.Utils.Common.secondsToNominalDiffTime <$> driverDrivenSearchReqExpiry,
            driverFeeCalculationTime = Kernel.Utils.Common.secondsToNominalDiffTime <$> driverFeeCalculationTime,
            driverFeeCalculatorBatchGap = Kernel.Utils.Common.secondsToNominalDiffTime <$> driverFeeCalculatorBatchGap,
            driverFeeCalculatorBatchSize = driverFeeCalculatorBatchSize,
            driverFeeMandateExecutionBatchSize = driverFeeMandateExecutionBatchSize,
            driverFeeMandateNotificationBatchSize = driverFeeMandateNotificationBatchSize,
            driverFeeOverlaySendingTimeLimitInDays = driverFeeOverlaySendingTimeLimitInDays,
            driverFeeRetryThresholdConfig = driverFeeRetryThresholdConfig,
            driverLocationAccuracyBuffer = driverLocationAccuracyBuffer,
            driverPaymentCycleBuffer = Kernel.Utils.Common.secondsToNominalDiffTime driverPaymentCycleBuffer,
            driverPaymentCycleDuration = Kernel.Utils.Common.secondsToNominalDiffTime driverPaymentCycleDuration,
            driverPaymentCycleStartTime = Kernel.Utils.Common.secondsToNominalDiffTime driverPaymentCycleStartTime,
            driverPaymentReminderInterval = Kernel.Utils.Common.secondsToNominalDiffTime driverPaymentReminderInterval,
            driverSmsReceivingLimit = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< driverSmsReceivingLimit,
            driverTimeSpentOnPickupThresholdOnCancel = driverTimeSpentOnPickupThresholdOnCancel,
            driverWalletConfig = driverWalletConfig',
            dropLocThreshold = dropLocThreshold,
            dummyFromLocation = fromMaybe Domain.Types.Location.dummyFromLocationData ((\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< dummyFromLocation),
            dummyShowDriverAdditions = dummyShowDriverAdditions,
            dummyToLocation = fromMaybe Domain.Types.Location.dummyToLocationData ((\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< dummyToLocation),
            dynamicReferralCodeEnabled = fromMaybe False dynamicReferralCodeEnabled,
            dynamicReferralCodeValidForMinutes = fromMaybe 60 dynamicReferralCodeValidForMinutes,
            editLocDriverPermissionNeeded = editLocDriverPermissionNeeded,
            editLocTimeThreshold = editLocTimeThreshold,
            emailOtpConfig = emailOtpConfig,
            enableDashboardSms = enableDashboardSms,
            enableExistingVehicleInBulkUpload = fromMaybe False enableExistingVehicleInBulkUpload,
            enableFaceVerification = enableFaceVerification,
            enableFareCalculatorV2 = enableFareCalculatorV2,
            enableMobileNumberValidation = enableMobileNumberValidation,
            enableOverchargingBlocker = fromMaybe False enableOverchargingBlocker,
            enableTollCrossedNotifications = enableTollCrossedNotifications,
            enableUdfForOffers = enableUdfForOffers,
            enableVendorCheckForCollectingDues = enableVendorCheckForCollectingDues,
            exotelAppIdMapping = exotelAppIdMapping,
            exotelStatusCheckSchedulerDelay = maybe 120 (.getSeconds) exotelStatusCheckSchedulerDelay,
            fakeOtpEmails = fakeOtpEmails,
            fakeOtpMobileNumbers = fakeOtpMobileNumbers,
            fareRecomputeDailyExtraKmsThreshold = fareRecomputeDailyExtraKmsThreshold,
            fareRecomputeWeeklyExtraKmsThreshold = fareRecomputeWeeklyExtraKmsThreshold,
            fcmConfig = Kernel.External.Notification.FCM.Types.FCMConfig {fcmUrl = fcmUrl', fcmServiceAccount = fcmServiceAccount, fcmTokenKeyPrefix = fcmTokenKeyPrefix},
            feedbackNotificationConfig = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< feedbackNotificationConfig,
            fleetAlertThreshold = fleetAlertThreshold,
            freeTrialDays = freeTrialDays,
            generateReferralCodeForFleet = generateReferralCodeForFleet,
            generateReferralCodeForOperator = generateReferralCodeForOperator,
            graceTimeForScheduledRidePickup = Kernel.Prelude.fromMaybe 300 (Kernel.Utils.Common.secondsToNominalDiffTime <$> graceTimeForScheduledRidePickup),
            includeDriverCurrentlyOnRide = includeDriverCurrentlyOnRide,
            isAAEnabledForRecurring = isAAEnabledForRecurring,
            isAvoidToll = isAvoidToll,
            isDeviceIdChecksRequired = isDeviceIdChecksRequired,
            isDynamicPricingQARCalEnabled = isDynamicPricingQARCalEnabled,
            isMLBasedDynamicPricingEnabled = fromMaybe False isMLBasedDynamicPricingEnabled,
            isPlanMandatory = isPlanMandatory,
            issueBreachConfig = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< issueBreachConfig,
            kaptureDisposition = kaptureDisposition,
            kaptureQueue = kaptureQueue,
            languagesToBeTranslated = languagesToBeTranslated,
            lastNdaysToCheckForPayoutOrderStatus = lastNdaysToCheckForPayoutOrderStatus,
            liveEKD = liveEKD,
            localAmbulanceNumbers = localAmbulanceNumbers,
            localPoliceNumbers = localPoliceNumbers,
            mandateExecutionRescheduleInterval = Kernel.Utils.Common.secondsToNominalDiffTime mandateExecutionRescheduleInterval,
            mandateNotificationRescheduleInterval = Kernel.Utils.Common.secondsToNominalDiffTime mandateNotificationRescheduleInterval,
            mandateValidity = mandateValidity,
            maxAllowedDocSizeInMB = maxAllowedDocSizeInMB,
            maxAllowedVideoDocSizeInMB = maxAllowedVideoDocSizeInMB,
            maxPayoutReferralForADay = maxPayoutReferralForADay,
            mediaFileSizeUpperLimit = mediaFileSizeUpperLimit,
            mediaFileUrlPattern = mediaFileUrlPattern,
            merchantId = Kernel.Types.Id.Id merchantId,
            merchantOperatingCityId = Kernel.Types.Id.Id merchantOperatingCityId,
            meterRideBulkLocUpdateBatchSize = fromMaybe 4 meterRideBulkLocUpdateBatchSize,
            minDistanceForStopFcm = fromMaybe 100 minDistanceForStopFcm,
            minLocationAccuracy = minLocationAccuracy,
            minRidesForCancellationScore = minRidesForCancellationScore,
            minRidesToUnlist = minRidesToUnlist,
            minThresholdForPassThroughDestination = minThresholdForPassThroughDestination,
            minmRentalAndScheduledBookingLeadTimeHours = fromMaybe 24 (Kernel.Types.Common.Hours <$> minmRentalAndScheduledBookingLeadTimeHours),
            nightSafetyEndTime = nightSafetyEndTime,
            nightSafetyRouteDeviationThreshold = nightSafetyRouteDeviationThreshold,
            nightSafetyStartTime = nightSafetyStartTime,
            normalRideBulkLocUpdateBatchSize = fromMaybe 98 normalRideBulkLocUpdateBatchSize,
            notificationRetryCountThreshold = notificationRetryCountThreshold,
            notificationRetryEligibleErrorCodes = notificationRetryEligibleErrorCodes,
            notificationRetryTimeGap = Kernel.Utils.Common.secondsToNominalDiffTime notificationRetryTimeGap,
            numOfCancellationsAllowed = numOfCancellationsAllowed,
            onboardingDocsCountLimit = onboardingDocsCountLimit,
            onboardingRetryTimeInHours = onboardingRetryTimeInHours,
            onboardingTryLimit = onboardingTryLimit,
            openMarketUnBlocked = openMarketUnBlocked,
            orderAndNotificationStatusCheckFallBackTime = Kernel.Utils.Common.secondsToNominalDiffTime orderAndNotificationStatusCheckFallBackTime,
            orderAndNotificationStatusCheckTime = Kernel.Utils.Common.secondsToNominalDiffTime orderAndNotificationStatusCheckTime,
            orderAndNotificationStatusCheckTimeLimit = Kernel.Utils.Common.secondsToNominalDiffTime orderAndNotificationStatusCheckTimeLimit,
            otpRideStartRestrictionRadius = otpRideStartRestrictionRadius,
            overlayBatchSize = overlayBatchSize,
            pastDaysRideCounter = pastDaysRideCounter,
            payoutBatchLimit = payoutBatchLimit,
            pickupLocThreshold = pickupLocThreshold,
            placeNameCacheExpiryDays = placeNameCacheExpiryDays,
            popupDelayToAddAsPenalty = popupDelayToAddAsPenalty,
            qarCalRadiusInKm = qarCalRadiusInKm,
            ratingAsDecimal = ratingAsDecimal,
            rcChangeThresholdDays = rcChangeThresholdDays,
            rcExpiryChecks = rcExpiryChecks,
            rcLimit = rcLimit,
            recentScheduledBookingsSafeLimit = fromMaybe 50 recentScheduledBookingsSafeLimit,
            recomputeDistanceThresholds = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< recomputeDistanceThresholds,
            recomputeIfPickupDropNotOutsideOfThreshold = recomputeIfPickupDropNotOutsideOfThreshold,
            referralLinkPassword = referralLinkPassword,
            refillVehicleModel = refillVehicleModel,
            requireRouteMappingInVehicle = fromMaybe False requireRouteMappingInVehicle,
            requiresOnboardingInspection = requiresOnboardingInspection,
            rideTimeEstimatedThreshold = rideTimeEstimatedThreshold,
            routeDeviationThreshold = routeDeviationThreshold,
            safetyTeamNumbers = safetyTeamNumbers,
            schedulePayoutForDay = schedulePayoutForDay,
            scheduleRideBufferTime = Kernel.Utils.Common.secondsToNominalDiffTime scheduleRideBufferTime,
            scheduledRideFilterExclusionThresholdHours = fromMaybe 2 (Kernel.Types.Common.Hours <$> scheduledRideFilterExclusionThresholdHours),
            scheduledRideJobRescheduleTime = Kernel.Prelude.fromMaybe 300 (Kernel.Utils.Common.secondsToNominalDiffTime <$> scheduledRideJobRescheduleTime),
            scheduledRideSearchRepeatLimit = fromMaybe 10 scheduledRideSearchRepeatLimit,
            searchRepeatLimit = searchRepeatLimit,
            snapToRoadConfidenceThreshold = snapToRoadConfidenceThreshold,
            specialDrivers = specialDrivers,
            specialLocationTags = specialLocationTags,
            specialZoneBookingOtpExpiry = specialZoneBookingOtpExpiry,
            stepFunctionToConvertCoins = stepFunctionToConvertCoins,
            subscription = subscription,
            subscriptionConfig = subscriptionConfig',
            subscriptionStartTime = subscriptionStartTime,
            thresholdCancellationPercentageToUnlist = thresholdCancellationPercentageToUnlist,
            thresholdCancellationScore = thresholdCancellationScore,
            timeDiffFromUtc = timeDiffFromUtc,
            toNotifyDriverForExtraKmsLimitExceed = toNotifyDriverForExtraKmsLimitExceed,
            updateNotificationStatusBatchSize = updateNotificationStatusBatchSize,
            updateOrderStatusBatchSize = updateOrderStatusBatchSize,
            updatePayoutStatusBatchSize = updatePayoutStatusBatchSize,
            updatedAt = updatedAt,
            upgradeTierDropRetentionTime = upgradeTierDropRetentionTime,
            upwardsRecomputeBuffer = upwardsRecomputeBuffer,
            upwardsRecomputeBufferPercentage = upwardsRecomputeBufferPercentage,
            useDBForAnalytics = useDBForAnalytics,
            useOfferListCache = useOfferListCache,
            useSilentFCMForForwardBatch = useSilentFCMForForwardBatch,
            useWithSnapToRoadFallback = useWithSnapToRoadFallback,
            validNameComparePercentage = validNameComparePercentage,
            variantsToEnableForSubscription = variantsToEnableForSubscription,
            volunteerSmsSendingLimit = (\val -> case Data.Aeson.fromJSON val of Data.Aeson.Success x -> Just x; Data.Aeson.Error _ -> Nothing) =<< volunteerSmsSendingLimit,
            weeklyConditionCooldownTimeHours = weeklyConditionCooldownTimeHours,
            weeklyMinRidesForBlocking = weeklyMinRidesForBlocking,
            weeklyMinRidesForNudging = weeklyMinRidesForNudging,
            weeklyOffenceSuspensionTimeHours = weeklyOffenceSuspensionTimeHours
          }

instance ToTType' Beam.TransporterConfig Domain.Types.TransporterConfig.TransporterConfig where
  toTType' (Domain.Types.TransporterConfig.TransporterConfig {..}) = do
    Beam.TransporterConfigT
      { Beam.aaEnabledClientSdkVersion = Just aaEnabledClientSdkVersion,
        Beam.aadhaarImageResizeConfig = Kernel.Prelude.toJSON <$> aadhaarImageResizeConfig,
        Beam.aadhaarVerificationRequired = aadhaarVerificationRequired,
        Beam.acStatusCheckGap = acStatusCheckGap,
        Beam.actualRideDistanceDiffThreshold = actualRideDistanceDiffThreshold,
        Beam.actualRideDistanceDiffThresholdIfWithinPickupDrop = actualRideDistanceDiffThresholdIfWithinPickupDrop,
        Beam.allowDashboardToPassVehicleDetails = allowDashboardToPassVehicleDetails,
        Beam.allowDefaultPlanAllocation = allowDefaultPlanAllocation,
        Beam.allowDriverToUseFleetRcs = allowDriverToUseFleetRcs,
        Beam.allowDuplicateAadhaar = allowDuplicateAadhaar,
        Beam.allowDuplicateGst = allowDuplicateGst,
        Beam.allowDuplicatePan = allowDuplicatePan,
        Beam.allowRcUnlinkWhenDriverOffline = allowRcUnlinkWhenDriverOffline,
        Beam.allowedReferralEntities = Just (Data.Text.pack . Kernel.Prelude.show <$> allowedReferralEntities),
        Beam.analyticsConfig = (Just . Data.Aeson.toJSON) analyticsConfig,
        Beam.approxRideDistanceDiffThreshold = approxRideDistanceDiffThreshold,
        Beam.arrivalTimeBufferOfVehicle = Kernel.Prelude.toJSON <$> arrivalTimeBufferOfVehicle,
        Beam.arrivedPickupThreshold = Just arrivedPickupThreshold,
        Beam.arrivedStopThreshold = arrivedStopThreshold,
        Beam.arrivingPickupThreshold = arrivingPickupThreshold,
        Beam.automaticRCActivationCutOff = automaticRCActivationCutOff,
        Beam.avgSpeedOfVehicle = Kernel.Prelude.toJSON <$> avgSpeedOfVehicle,
        Beam.badDebtBatchSize = badDebtBatchSize,
        Beam.badDebtRescheduleTime = Kernel.Utils.Common.nominalDiffTimeToSeconds badDebtRescheduleTime,
        Beam.badDebtSchedulerTime = Kernel.Utils.Common.nominalDiffTimeToSeconds badDebtSchedulerTime,
        Beam.badDebtTimeThreshold = badDebtTimeThreshold,
        Beam.bankErrorExpiry = Kernel.Utils.Common.nominalDiffTimeToSeconds bankErrorExpiry,
        Beam.bookAnyVehicleDowngradeLevel = bookAnyVehicleDowngradeLevel,
        Beam.bulkWaiveOffLimit = Just bulkWaiveOffLimit,
        Beam.cacheOfferListByDriverId = cacheOfferListByDriverId,
        Beam.cachedDevicesOSForSearchRequest = Just (Data.Text.pack . Kernel.Prelude.show <$> cachedDevicesOSForSearchRequest),
        Beam.canAddCancellationFee = canAddCancellationFee,
        Beam.canDowngradeToHatchback = canDowngradeToHatchback,
        Beam.canDowngradeToSedan = canDowngradeToSedan,
        Beam.canDowngradeToTaxi = canDowngradeToTaxi,
        Beam.canSuvDowngradeToHatchback = Just canSuvDowngradeToHatchback,
        Beam.canSuvDowngradeToTaxi = canSuvDowngradeToTaxi,
        Beam.canSwitchToInterCity = canSwitchToInterCity,
        Beam.canSwitchToRental = canSwitchToRental,
        Beam.cancellationDistDiff = cancellationDistDiff,
        Beam.cancellationFee = cancellationFee,
        Beam.cancellationFeeCycle = cancellationFeeCycle,
        Beam.cancellationFeeDisputeLimit = cancellationFeeDisputeLimit,
        Beam.cancellationFeeDisputeWindow = cancellationFeeDisputeWindow,
        Beam.cancellationFeeVendor = cancellationFeeVendor,
        Beam.cancellationRateCalculationThreshold = cancellationRateCalculationThreshold,
        Beam.cancellationRateSlabConfig = Data.Aeson.toJSON <$> cancellationRateSlabConfig,
        Beam.cancellationRateThresholdDaily = cancellationRateThresholdDaily,
        Beam.cancellationRateThresholdWeekly = cancellationRateThresholdWeekly,
        Beam.cancellationRateWindow = cancellationRateWindow,
        Beam.cancellationTimeDiff = Kernel.Utils.Common.nominalDiffTimeToSeconds cancellationTimeDiff,
        Beam.checkImageExtractionForDashboard = checkImageExtractionForDashboard,
        Beam.coinConversionRate = coinConversionRate,
        Beam.coinExpireTime = Kernel.Utils.Common.nominalDiffTimeToSeconds coinExpireTime,
        Beam.coinFeature = coinFeature,
        Beam.considerDriversForSearch = considerDriversForSearch,
        Beam.considerSpecialZoneRideChargesInFreeTrial = considerSpecialZoneRideChargesInFreeTrial,
        Beam.considerSpecialZoneRidesForPlanCharges = considerSpecialZoneRidesForPlanCharges,
        Beam.createDocumentRequired = createDocumentRequired,
        Beam.createdAt = createdAt,
        Beam.crossTravelCities = crossTravelCities,
        Beam.currency = Just currency,
        Beam.dailyConditionCooldownTimeHours = dailyConditionCooldownTimeHours,
        Beam.dailyMinRidesForBlocking = dailyMinRidesForBlocking,
        Beam.dailyMinRidesForNudging = dailyMinRidesForNudging,
        Beam.dailyOffenceSuspensionTimeHours = dailyOffenceSuspensionTimeHours,
        Beam.deactivateRCOnUnlink = deactivateRCOnUnlink,
        Beam.defaultPopupDelay = defaultPopupDelay,
        Beam.deleteDriverBankAccountWhenLinkToFleet = deleteDriverBankAccountWhenLinkToFleet,
        Beam.demandHotspotsConfig = Kernel.Prelude.toJSON <$> demandHotspotsConfig,
        Beam.disableDriverWhenUnlinkingVehicle = disableDriverWhenUnlinkingVehicle,
        Beam.disableListScheduledBookingAPI = Just disableListScheduledBookingAPI,
        Beam.distanceUnit = Kernel.Prelude.Just distanceUnit,
        Beam.distanceWeightage = distanceWeightage,
        Beam.dlNumberVerification = dlNumberVerification,
        Beam.dpBlackListedGeohash = dpBlackListedGeohash,
        Beam.dpGeoHashPercision = dpGeoHashPercision,
        Beam.dpWhiteListedGeohash = dpWhiteListedGeohash,
        Beam.driverAutoPayExecutionTime = Kernel.Utils.Common.nominalDiffTimeToSeconds driverAutoPayExecutionTime,
        Beam.driverAutoPayExecutionTimeFallBack = Kernel.Utils.Common.nominalDiffTimeToSeconds driverAutoPayExecutionTimeFallBack,
        Beam.driverAutoPayNotificationTime = Kernel.Utils.Common.nominalDiffTimeToSeconds driverAutoPayNotificationTime,
        Beam.driverCallingOption = driverCallingOption,
        Beam.driverDistanceToPickupThresholdOnCancel = driverDistanceToPickupThresholdOnCancel,
        Beam.driverDistanceTravelledOnPickupThresholdOnCancel = driverDistanceTravelledOnPickupThresholdOnCancel,
        Beam.driverDrivenSearchReqExpiry = Kernel.Utils.Common.nominalDiffTimeToSeconds <$> driverDrivenSearchReqExpiry,
        Beam.driverFeeCalculationTime = Kernel.Utils.Common.nominalDiffTimeToSeconds <$> driverFeeCalculationTime,
        Beam.driverFeeCalculatorBatchGap = Kernel.Utils.Common.nominalDiffTimeToSeconds <$> driverFeeCalculatorBatchGap,
        Beam.driverFeeCalculatorBatchSize = driverFeeCalculatorBatchSize,
        Beam.driverFeeMandateExecutionBatchSize = driverFeeMandateExecutionBatchSize,
        Beam.driverFeeMandateNotificationBatchSize = driverFeeMandateNotificationBatchSize,
        Beam.driverFeeOverlaySendingTimeLimitInDays = driverFeeOverlaySendingTimeLimitInDays,
        Beam.driverFeeRetryThresholdConfig = driverFeeRetryThresholdConfig,
        Beam.driverLocationAccuracyBuffer = driverLocationAccuracyBuffer,
        Beam.driverPaymentCycleBuffer = Kernel.Utils.Common.nominalDiffTimeToSeconds driverPaymentCycleBuffer,
        Beam.driverPaymentCycleDuration = Kernel.Utils.Common.nominalDiffTimeToSeconds driverPaymentCycleDuration,
        Beam.driverPaymentCycleStartTime = Kernel.Utils.Common.nominalDiffTimeToSeconds driverPaymentCycleStartTime,
        Beam.driverPaymentReminderInterval = Kernel.Utils.Common.nominalDiffTimeToSeconds driverPaymentReminderInterval,
        Beam.driverSmsReceivingLimit = Kernel.Prelude.toJSON <$> driverSmsReceivingLimit,
        Beam.driverTimeSpentOnPickupThresholdOnCancel = driverTimeSpentOnPickupThresholdOnCancel,
        Beam.driverWalletConfig = (Just . Data.Aeson.toJSON) driverWalletConfig,
        Beam.dropLocThreshold = dropLocThreshold,
        Beam.dummyFromLocation = Just $ toJSON dummyFromLocation,
        Beam.dummyShowDriverAdditions = dummyShowDriverAdditions,
        Beam.dummyToLocation = Just $ toJSON dummyToLocation,
        Beam.dynamicReferralCodeEnabled = Just dynamicReferralCodeEnabled,
        Beam.dynamicReferralCodeValidForMinutes = Just dynamicReferralCodeValidForMinutes,
        Beam.editLocDriverPermissionNeeded = editLocDriverPermissionNeeded,
        Beam.editLocTimeThreshold = editLocTimeThreshold,
        Beam.emailOtpConfig = emailOtpConfig,
        Beam.enableDashboardSms = enableDashboardSms,
        Beam.enableExistingVehicleInBulkUpload = Just enableExistingVehicleInBulkUpload,
        Beam.enableFaceVerification = enableFaceVerification,
        Beam.enableFareCalculatorV2 = enableFareCalculatorV2,
        Beam.enableMobileNumberValidation = enableMobileNumberValidation,
        Beam.enableOverchargingBlocker = Just enableOverchargingBlocker,
        Beam.enableTollCrossedNotifications = enableTollCrossedNotifications,
        Beam.enableUdfForOffers = enableUdfForOffers,
        Beam.enableVendorCheckForCollectingDues = enableVendorCheckForCollectingDues,
        Beam.exotelAppIdMapping = exotelAppIdMapping,
        Beam.exotelStatusCheckSchedulerDelay = Just $ Kernel.Types.Common.Seconds exotelStatusCheckSchedulerDelay,
        Beam.fakeOtpEmails = fakeOtpEmails,
        Beam.fakeOtpMobileNumbers = fakeOtpMobileNumbers,
        Beam.fareRecomputeDailyExtraKmsThreshold = fareRecomputeDailyExtraKmsThreshold,
        Beam.fareRecomputeWeeklyExtraKmsThreshold = fareRecomputeWeeklyExtraKmsThreshold,
        Beam.fcmServiceAccount = (.fcmServiceAccount) fcmConfig,
        Beam.fcmTokenKeyPrefix = (.fcmTokenKeyPrefix) fcmConfig,
        Beam.fcmUrl = Kernel.Prelude.showBaseUrl $ (.fcmUrl) fcmConfig,
        Beam.feedbackNotificationConfig = Data.Aeson.toJSON <$> feedbackNotificationConfig,
        Beam.fleetAlertThreshold = fleetAlertThreshold,
        Beam.freeTrialDays = freeTrialDays,
        Beam.generateReferralCodeForFleet = generateReferralCodeForFleet,
        Beam.generateReferralCodeForOperator = generateReferralCodeForOperator,
        Beam.graceTimeForScheduledRidePickup = Kernel.Prelude.Just $ Kernel.Utils.Common.nominalDiffTimeToSeconds graceTimeForScheduledRidePickup,
        Beam.includeDriverCurrentlyOnRide = includeDriverCurrentlyOnRide,
        Beam.isAAEnabledForRecurring = isAAEnabledForRecurring,
        Beam.isAvoidToll = isAvoidToll,
        Beam.isDeviceIdChecksRequired = isDeviceIdChecksRequired,
        Beam.isDynamicPricingQARCalEnabled = isDynamicPricingQARCalEnabled,
        Beam.isMLBasedDynamicPricingEnabled = Just isMLBasedDynamicPricingEnabled,
        Beam.isPlanMandatory = isPlanMandatory,
        Beam.issueBreachConfig = Kernel.Prelude.toJSON <$> issueBreachConfig,
        Beam.kaptureDisposition = kaptureDisposition,
        Beam.kaptureQueue = kaptureQueue,
        Beam.languagesToBeTranslated = languagesToBeTranslated,
        Beam.lastNdaysToCheckForPayoutOrderStatus = lastNdaysToCheckForPayoutOrderStatus,
        Beam.liveEKD = liveEKD,
        Beam.localAmbulanceNumbers = localAmbulanceNumbers,
        Beam.localPoliceNumbers = localPoliceNumbers,
        Beam.mandateExecutionRescheduleInterval = Kernel.Utils.Common.nominalDiffTimeToSeconds mandateExecutionRescheduleInterval,
        Beam.mandateNotificationRescheduleInterval = Kernel.Utils.Common.nominalDiffTimeToSeconds mandateNotificationRescheduleInterval,
        Beam.mandateValidity = mandateValidity,
        Beam.maxAllowedDocSizeInMB = maxAllowedDocSizeInMB,
        Beam.maxAllowedVideoDocSizeInMB = maxAllowedVideoDocSizeInMB,
        Beam.maxPayoutReferralForADay = maxPayoutReferralForADay,
        Beam.mediaFileSizeUpperLimit = mediaFileSizeUpperLimit,
        Beam.mediaFileUrlPattern = mediaFileUrlPattern,
        Beam.merchantId = Kernel.Types.Id.getId merchantId,
        Beam.merchantOperatingCityId = Kernel.Types.Id.getId merchantOperatingCityId,
        Beam.meterRideBulkLocUpdateBatchSize = Just meterRideBulkLocUpdateBatchSize,
        Beam.minDistanceForStopFcm = Just minDistanceForStopFcm,
        Beam.minLocationAccuracy = minLocationAccuracy,
        Beam.minRidesForCancellationScore = minRidesForCancellationScore,
        Beam.minRidesToUnlist = minRidesToUnlist,
        Beam.minThresholdForPassThroughDestination = minThresholdForPassThroughDestination,
        Beam.minmRentalAndScheduledBookingLeadTimeHours = Kernel.Prelude.Just $ Kernel.Types.Common.getHours minmRentalAndScheduledBookingLeadTimeHours,
        Beam.nightSafetyEndTime = nightSafetyEndTime,
        Beam.nightSafetyRouteDeviationThreshold = nightSafetyRouteDeviationThreshold,
        Beam.nightSafetyStartTime = nightSafetyStartTime,
        Beam.normalRideBulkLocUpdateBatchSize = Just normalRideBulkLocUpdateBatchSize,
        Beam.notificationRetryCountThreshold = notificationRetryCountThreshold,
        Beam.notificationRetryEligibleErrorCodes = notificationRetryEligibleErrorCodes,
        Beam.notificationRetryTimeGap = Kernel.Utils.Common.nominalDiffTimeToSeconds notificationRetryTimeGap,
        Beam.numOfCancellationsAllowed = numOfCancellationsAllowed,
        Beam.onboardingDocsCountLimit = onboardingDocsCountLimit,
        Beam.onboardingRetryTimeInHours = onboardingRetryTimeInHours,
        Beam.onboardingTryLimit = onboardingTryLimit,
        Beam.openMarketUnBlocked = openMarketUnBlocked,
        Beam.orderAndNotificationStatusCheckFallBackTime = Kernel.Utils.Common.nominalDiffTimeToSeconds orderAndNotificationStatusCheckFallBackTime,
        Beam.orderAndNotificationStatusCheckTime = Kernel.Utils.Common.nominalDiffTimeToSeconds orderAndNotificationStatusCheckTime,
        Beam.orderAndNotificationStatusCheckTimeLimit = Kernel.Utils.Common.nominalDiffTimeToSeconds orderAndNotificationStatusCheckTimeLimit,
        Beam.otpRideStartRestrictionRadius = otpRideStartRestrictionRadius,
        Beam.overlayBatchSize = overlayBatchSize,
        Beam.pastDaysRideCounter = pastDaysRideCounter,
        Beam.payoutBatchLimit = payoutBatchLimit,
        Beam.pickupLocThreshold = pickupLocThreshold,
        Beam.placeNameCacheExpiryDays = placeNameCacheExpiryDays,
        Beam.popupDelayToAddAsPenalty = popupDelayToAddAsPenalty,
        Beam.qarCalRadiusInKm = qarCalRadiusInKm,
        Beam.ratingAsDecimal = ratingAsDecimal,
        Beam.rcChangeThresholdDays = rcChangeThresholdDays,
        Beam.rcExpiryChecks = rcExpiryChecks,
        Beam.rcLimit = rcLimit,
        Beam.recentScheduledBookingsSafeLimit = Just recentScheduledBookingsSafeLimit,
        Beam.recomputeDistanceThresholds = Kernel.Prelude.toJSON <$> recomputeDistanceThresholds,
        Beam.recomputeIfPickupDropNotOutsideOfThreshold = recomputeIfPickupDropNotOutsideOfThreshold,
        Beam.referralLinkPassword = referralLinkPassword,
        Beam.refillVehicleModel = refillVehicleModel,
        Beam.requireRouteMappingInVehicle = Just requireRouteMappingInVehicle,
        Beam.requiresOnboardingInspection = requiresOnboardingInspection,
        Beam.rideTimeEstimatedThreshold = rideTimeEstimatedThreshold,
        Beam.routeDeviationThreshold = routeDeviationThreshold,
        Beam.safetyTeamNumbers = safetyTeamNumbers,
        Beam.schedulePayoutForDay = schedulePayoutForDay,
        Beam.scheduleRideBufferTime = Kernel.Utils.Common.nominalDiffTimeToSeconds scheduleRideBufferTime,
        Beam.scheduledRideFilterExclusionThresholdHours = Kernel.Prelude.Just $ Kernel.Types.Common.getHours scheduledRideFilterExclusionThresholdHours,
        Beam.scheduledRideJobRescheduleTime = Kernel.Prelude.Just $ Kernel.Utils.Common.nominalDiffTimeToSeconds scheduledRideJobRescheduleTime,
        Beam.scheduledRideSearchRepeatLimit = Just scheduledRideSearchRepeatLimit,
        Beam.searchRepeatLimit = searchRepeatLimit,
        Beam.snapToRoadConfidenceThreshold = snapToRoadConfidenceThreshold,
        Beam.specialDrivers = specialDrivers,
        Beam.specialLocationTags = specialLocationTags,
        Beam.specialZoneBookingOtpExpiry = specialZoneBookingOtpExpiry,
        Beam.stepFunctionToConvertCoins = stepFunctionToConvertCoins,
        Beam.subscription = subscription,
        Beam.subscriptionConfig = (Just . Data.Aeson.toJSON) subscriptionConfig,
        Beam.subscriptionStartTime = subscriptionStartTime,
        Beam.thresholdCancellationPercentageToUnlist = thresholdCancellationPercentageToUnlist,
        Beam.thresholdCancellationScore = thresholdCancellationScore,
        Beam.timeDiffFromUtc = timeDiffFromUtc,
        Beam.toNotifyDriverForExtraKmsLimitExceed = toNotifyDriverForExtraKmsLimitExceed,
        Beam.updateNotificationStatusBatchSize = updateNotificationStatusBatchSize,
        Beam.updateOrderStatusBatchSize = updateOrderStatusBatchSize,
        Beam.updatePayoutStatusBatchSize = updatePayoutStatusBatchSize,
        Beam.updatedAt = updatedAt,
        Beam.upgradeTierDropRetentionTime = upgradeTierDropRetentionTime,
        Beam.upwardsRecomputeBuffer = upwardsRecomputeBuffer,
        Beam.upwardsRecomputeBufferPercentage = upwardsRecomputeBufferPercentage,
        Beam.useDBForAnalytics = useDBForAnalytics,
        Beam.useOfferListCache = useOfferListCache,
        Beam.useSilentFCMForForwardBatch = useSilentFCMForForwardBatch,
        Beam.useWithSnapToRoadFallback = useWithSnapToRoadFallback,
        Beam.validNameComparePercentage = validNameComparePercentage,
        Beam.variantsToEnableForSubscription = variantsToEnableForSubscription,
        Beam.volunteerSmsSendingLimit = Kernel.Prelude.toJSON <$> volunteerSmsSendingLimit,
        Beam.weeklyConditionCooldownTimeHours = weeklyConditionCooldownTimeHours,
        Beam.weeklyMinRidesForBlocking = weeklyMinRidesForBlocking,
        Beam.weeklyMinRidesForNudging = weeklyMinRidesForNudging,
        Beam.weeklyOffenceSuspensionTimeHours = weeklyOffenceSuspensionTimeHours
      }
